/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2024-05-30 15:34:27
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2024-06-03 09:31:27
 * @FilePath: \driving-training-admin\src\apis\system\dict.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import axios from '../../axios/index'

export interface dictPageProps {
    type?: string //字典类型 1后台管理，2小程序
    current?: number
    size?: number
    dictCode?: string
    dictName?: string
}

//字典分页列表
export const dictList = (params: dictPageProps) => {
    return axios({
        method: 'get',
        url: '/api/system/dict/manage/getPageList',
        params
    })
}

export interface dictItemOperateProps {
    description?: string
    dictId?: string //字典id
    disable?: number
    id?: string
    itemText?: string
    itemValue?: string
    color?: string
    sortOrder?: number
}

export interface dictOperateProps {
    description?: string
    dictCode?: string //字典id
    dictType?: number //字典类型 1后台管理，2小程序
    dictName?: string
    id?: string
}

//新增字典
export const dictAdd = (data: dictOperateProps) => {
    return axios({
        method: 'post',
        url: '/api/system/dict/manage/add',
        data
    })
}

//修改字典
export const dictEdit = (data: dictOperateProps) => {
    return axios({
        method: 'post',
        url: '/api/system/dict/manage/edit',
        data
    })
}

//单个字典信息
export const dictInformationByDictId = (dictId: string, current: number, size: number) => {
    return axios({
        method: 'get',
        url: '/api/system/dictItem/manage/getPageList',
        params: { dictId, current, size }
    })
}

//删除字典
export const dictDetele = (id: string) => {
    return axios({
        method: 'delete',
        url: '/api/system/dict/manage/remove',
        params: { id }
    })
}

//新增item字典
export const dictItemAdd = (data: dictItemOperateProps) => {
    return axios({
        method: 'post',
        url: '/api/system/dictItem/manage/add',
        data
    })
}

//修改item字典
export const dictItemEdit = (data: dictItemOperateProps) => {
    return axios({
        method: 'post',
        url: '/api/system/dictItem/manage/edit',
        data
    })
}

//删除item字典
export const dicItemtDetele = (id: string) => {
    return axios({
        method: 'delete',
        url: '/api/system/dictItem/manage/remove',
        params: { id }
    })
}

//获取所有的字典数据
export const getAllDict = () => {
    return axios({
        method: 'get',
        url: '/api/system/dictItem/manage/all'
    })
}
